unit menu;

interface

uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TbtnMenu = class(TFrame)
    LabMenu: TLabel;
    ImgMenu: TImage;
    procedure FrameResize(Sender: TObject);
    procedure LabMenuMouseEnter(Sender: TObject);
    procedure LabMenuMouseLeave(Sender: TObject);
    procedure LabMenuClick(Sender: TObject);
  private
    { Private declarations }
    FCaption:string;
    procedure SetCaption(value:string);
  published
    property Caption:string Read FCaption write SetCaption;
  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

procedure Register;
begin
 RegisterComponents('Samples',[TbtnMenu])
end;

procedure TbtnMenu.SetCaption(value:string);
begin
  FCaption:=Value;
  LabMenu.Caption:=FCaption;
end;

procedure TbtnMenu.FrameResize(Sender: TObject);
begin
  ImgMenu.Top:=(Height-ImgMenu.Height) Div 2;
  LabMenu.Top:=(Height-LabMenu.Height) Div 2;
  LabMenu.Width:=Width-LabMenu.Left-2;
end;

procedure TbtnMenu.LabMenuMouseEnter(Sender: TObject);
begin
  LabMenu.Font.Style := LabMenu.Font.Style+[fsUnderLine];
end;

procedure TbtnMenu.LabMenuMouseLeave(Sender: TObject);
begin
  LabMenu.Font.Style := LabMenu.Font.Style-[fsUnderLine];
end;

procedure TbtnMenu.LabMenuClick(Sender: TObject);
begin
  if Assigned(OnClick) then OnClick(Sender);
end;

end.
